package com.byzh.singleton;

/**
 * 单例模式懒汉模式
 * 
 * @author sky
 *
 */
public class SingletonLazy {

    private static final UserDao userDao = null;

    private SingletonLazy() {
        throw new UnsupportedOperationException("sigleton pattern unsuport constructors init");
    }

    public static UserDao getInstance() {
        if (userDao == null) {
            synchronized (userDao) {
                if (userDao == null) {
                    return new UserDao();
                } else {
                    return userDao;
                }
            }
        } else {
            return userDao;
        }
    }

}
